﻿using System;
using UnityEngine;

// Token: 0x0200002B RID: 43
public class VrPlayerArena : MonoBehaviour
{
	// Token: 0x060000BD RID: 189 RVA: 0x00010090 File Offset: 0x0000E290
	private void Start()
	{
		this.body = base.GetComponent<BodyScript>();
	}

	// Token: 0x060000BE RID: 190 RVA: 0x000100A0 File Offset: 0x0000E2A0
	private void Update()
	{
		if ((this.body.health <= 0f && GameManager.main.vrAlly) || (!this.body.gameObject.activeSelf && GameManager.main.vrAlly))
		{
			GameManager.main.vrAlly.gameObject.AddComponent<PlayerInput>();
			if (BloodDamageUI.main)
			{
				BloodDamageUI.main.body = GameManager.main.vrAlly;
				BloodDamageUI.main.playedCorpusSound = false;
				BloodDamageUI.main.lowHealthAudio.Play();
			}
			if (CameraController.main)
			{
				CameraController.main.checkTransform = GameManager.main.vrAlly.torso.transform;
			}
			if (MusicManager.main)
			{
				MusicManager.main.body = GameManager.main.vrAlly;
			}
			if (GameManager.main.vrAlly.GetComponent<AI>())
			{
				Object.Destroy(GameManager.main.vrAlly.GetComponent<AI>());
			}
			Object.Destroy(GameManager.main.playerBody.GetComponent<PlayerInput>());
			Object.Destroy(GameManager.main.playerBody.GetComponent<HealthRegen>());
			GameManager.main.playerBody.health = -1f;
			GameManager.main.playerBody.gameObject.AddComponent<VrBuddyDeathBehaviour>();
			GameManager.main.vrAlly.overallForce += (float)PlayerPrefs.GetInt("up1") * 0.2f;
			GameManager.main.vrAlly.attackTimeMult += (float)PlayerPrefs.GetInt("up1") * 0.05f;
			GameManager.main.vrAlly.moveForce += (float)PlayerPrefs.GetInt("up2") * 10f;
			GameManager.main.vrAlly.maxSpeed += (float)PlayerPrefs.GetInt("up2") * 0.5f;
			GameManager.main.vrAlly.turnSpeed += (float)PlayerPrefs.GetInt("up2") * 0.1f;
			GameManager.main.vrAlly.jumpForce += (float)PlayerPrefs.GetInt("up2") * 1.5f;
			GameManager.main.vrAlly.health += (float)PlayerPrefs.GetInt("up3") * 8f;
			GameManager.main.vrAlly.maxHealth += (float)PlayerPrefs.GetInt("up3") * 8f;
			GameManager.main.vrAlly.hitStunMult -= (float)PlayerPrefs.GetInt("up5") * 0.08f;
			GameManager.main.vrAlly.gameObject.AddComponent<HealthRegen>().hpPerSec = GameManager.main.PlayerRegenByDifficulty();
			GameManager.main.vrAlly.gameObject.AddComponent<VrPlayerSpawnBehaviour>();
			if (GameManager.main.bodies.Contains(GameManager.main.vrAlly))
			{
				GameManager.main.bodies.Remove(GameManager.main.vrAlly);
			}
			GameManager.main.playerBody = GameManager.main.vrAlly;
			GameManager.main.vrAlly = null;
			if (GameManager.main.vrGuys.Contains(GameManager.main.playerBody.gameObject))
			{
				GameManager.main.vrGuys.Remove(GameManager.main.playerBody.gameObject);
			}
			Sound.Play(Resources.Load<AudioClip>("Sounds/instaSwitch"), Vector2.zero, true, false, 1f);
			GameManager.main.playerBody.gameObject.AddComponent<VrPlayerArena>();
			PauseManager.main.TryUnlockAchievement(14);
			Object.Destroy(this);
		}
	}

	// Token: 0x0400019F RID: 415
	private BodyScript body;
}
